<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateShopOrderRefund extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('shop_order_refund',['engine'=>'InnoDB'])->setComment('订单售后');
        $table->addColumn(Column::tinyInteger('type')->setDefault(1)->setComment('售后类型：1退货退款，2换货'));
        $table->addColumn(Column::integer('uid')->setDefault(0)->setComment('用户id'));
        $table->addColumn(Column::integer('order_id')->setDefault(0)->setComment('订单id'));
        $table->addColumn(Column::tinyInteger('status')->setDefault(1)->setComment('售后状态：-1售后已取消 0拒绝售后，1申请售后，2同意换货，3用户已寄回，4售后已退款，5售后已换货'));
        $table->addColumn(Column::text('address_info')->setNullable()->setComment('换货地址'));
        $table->addColumn(Column::string('express_number',50)->setNullable()->setComment('快递单号'));
        $table->addColumn(Column::string('express_compay',50)->setNullable()->setComment('快递公司'));
        $table->addColumn(Column::decimal('price',10,2)->setDefault(0)->setComment('退款金额'));
        $table->addColumn(Column::string('img',500)->setNullable()->setComment('售后图片凭证'));
        $table->addColumn(Column::string('desc',500)->setNullable()->setComment('申请售后描述'));
        $table->addTimestamps('create_at');
        $table->create();
    }
}
